package com.ys.utils.help;

import com.ys.base.EnumType;

/**
 * @author quxinjun
 * @version 1.0.0
 * @ClassName TipUtils.java
 * @Description 提示帮助类
 * @createTime 2021年05月27日 11:40:00
 */
public class TipUtils {

    public static final String GROUP_DISSOLVE = "该群已被群主解散";
    public static final String GROUP_TURN = "%s 转让了该群";
    public static final String GROUP_MOVED = "%s 将 %s 移出群聊";
    public static final String GROUP_BE_REMOVED = "您已被 %s 移出群聊";
    public static final String USER_UPDATE_GROUP_NICK_NAME = "%s 在本群群昵称修改为 %s";
    public static final String GROUP_SET_NAME = "%s 将群名称设置为 %s";
    public static final String GROUP_SET_NOTICE = "%s  修改了群公告";
    public static final String GROUP_AUDIT = "%s 开启了入群需审核功能";
    public static final String GROUP_NON_AUDIT = "%s 取消了入群需审核功能";
    public static final String GROUP_EXIT = "%s 退出了群聊";
    public static final String GROUP_INVITE = "%s 邀请 %s 加入群聊";
    public static final String GROUP_AGREE = "%s 同意 %s 加入群聊";
    public static final String GROUP_SET_MANAGER = "%s 成为了管理员";
    public static final String GROUP_SET_MEMBER = "%s 成为了普通成员";
    public static final String GROUP_SET_BANNED = "%s 将 %s 禁言 %s";
    public static final String GROUP_SET_BAN_GRAD = "%s 禁止 %s 抢红包";
    public static final String GROUP_CANCEL_BANNED = "%s 取消了 %s 的禁言";
    public static final String GROUP_CANCEL_BAN_GRAD = "%s 允许了 %s 可以在本群抢红包";
    public static final String GROUP_IS_BANNED = "您被 %s 禁言了 %s";
    public static final String GROUP_IS_GRAD = "您被 %s 禁止在本群抢红包";
    public static final String GROUP_ALL_BANNED = "%s 开启了全员禁言";
    public static final String GROUP_NON_ALL_BANNED = "%s 取消了全员禁言";
    public static final String GROUP_MEMBER_PROTECT = "%s 开启了成员保护模式";
    public static final String GROUP_NON_MEMBER_PROTECT = "%s 关闭了成员保护模式";
    public static final String GROUP_JOIN = "%s 邀请你加入群聊";
    public static final String GROUP_IS_NON_BANNED = "您被 %s 取消了禁言";
    public static final String GROUP_IS_NON_BAN_GRAD = "您被 %s 允许了在本群抢红包";
    public static final String GROUP_INVITE_TITLE_1 = "%s 邀请你加入群聊";
    public static final String GROUP_INVITE_TITLE_2 = "%s 邀请你加入 %s 的群聊";
    public static final String GROUP_UNDO_MESSAGE = "%s 撤销了一条消息";
    public static final String GROUP_SCREEN_HOSTS = "%s 在 %s 对该群发起了截屏";
    public static final String SET_SCREEN_NOTICE = "您开启了截屏通知";
    public static final String SET_SCREEN_NOTICE_NON = "您关闭了截屏通知";
    public static final String SET_ADVERT_INTERCEPT = "%s 开启了广告拦截";
    public static final String SET_ADVERT_INTERCEPT_NON = "%s 关闭了广告拦截";
    private static final String GROUP_SCREEN_NOTICE = "群主开启了截屏通知";
    private static final String GROUP_SCREEN_NOTICE_NON = "群主关闭了截屏通知";
    private static final String SET_BAN_GRAD = "%s 允许全员抢红包";
    private static final String SET_BAN_GRAD_NON = "%s 禁止全员抢红包";

    private static String getName(String groupId, String uid) {
//        return UserUtils.getCacheUserNickName(groupId, uid, UserUtils.getCacheUser(uid).getNickName());
        return UserUtils.getCacheUser(uid).getNickName();
    }

    /**
     * @param groupId  组id
     * @param uid      操作人id
     * @param inviteId 邀请人id
     * @title invite
     * @description 邀请
     * @author quxinjun
     * @updateTime 2021/5/27 14:17
     * @return: java.lang.String
     */
    public static String invite(String groupId, String uid, String inviteId) {
//        return String.format(GROUP_INVITE, getName(groupId, inviteId), getName(groupId, uid));
        return String.format(GROUP_INVITE, getName(groupId, inviteId), getName(groupId, uid));
    }

    /**
     * @param groupId 群组id
     * @param uid     用户id
     * @title groupExit
     * @description 退出群聊
     * @author quxinjun
     * @updateTime 2021/5/27 14:09
     * @return: java.lang.String
     */
    public static String groupExit(String groupId, String uid) {
        return String.format(GROUP_EXIT, getName(groupId, uid));
    }

    /**
     * @param groupId 组别id
     * @param uid     操作人id
     * @param value   值
     * @param type    类型
     * @title setGroupBase
     * @description
     * @author quxinjun
     * @updateTime 2021/5/27 14:04
     * @return: java.lang.String
     */
    public static String setGroupBase(String groupId, String uid, Object value, Integer type) {
        String result = null;
        switch (type) {
            case 0:
                result = String.format(USER_UPDATE_GROUP_NICK_NAME, UserUtils.getCacheUser(uid).getNickName(), value);
                break;
            case 2:
                result = String.format(GROUP_SET_NAME, getName(groupId, uid), value);
                break;
            case 3:
                result = String.format(GROUP_SET_NOTICE, getName(groupId, uid));
                break;
            case 4:
                result = String.format((Boolean) value ? GROUP_AUDIT : GROUP_NON_AUDIT, getName(groupId, uid));
                break;
            case 5:
                result = String.format((Boolean) value ? GROUP_ALL_BANNED : GROUP_NON_ALL_BANNED, getName(groupId, uid));
                break;
            case 6:
                result = String.format((Boolean) value ? GROUP_MEMBER_PROTECT : GROUP_NON_MEMBER_PROTECT, getName(groupId, uid));
                break;
            case 8:
                result = (Boolean) value ? GROUP_SCREEN_NOTICE : GROUP_SCREEN_NOTICE_NON;
                break;
            case 9:
                result = String.format((Boolean) value ? SET_ADVERT_INTERCEPT : SET_ADVERT_INTERCEPT_NON, getName(groupId, uid));
                break;
            case 10:
                result = (Boolean) value ?"本群禁止红包功能" : "本群开启红包功能";
                break;
            default:
                break;
        }
        return result;
    }


    /**
     * @param groupId 组id
     * @param uid     用户id
     * @title turnGroupTip
     * @description 转让群提示
     * @author quxinjun
     * @updateTime 2021/5/27 11:47
     * @return: java.lang.String
     */
    public static String turnGroupTip(String groupId, String uid) {
        return String.format(GROUP_TURN, getName(groupId, uid));
    }

    /**
     * @param groupId 组id
     * @param uid     用户id
     * @title beRemovedTip
     * @description 谁被移出了群聊
     * @author quxinjun
     * @updateTime 2021/5/27 11:53
     * @return: java.lang.String
     */
    public static String beRemovedTip(String groupId, String uid) {
        return String.format(GROUP_BE_REMOVED, getName(groupId, uid));
    }


    /**
     * @param groupId 群组id
     * @param uid     操作人id
     * @param delId   被删除的人的id
     * @title moveGroup
     * @description 谁把谁移出群聊
     * @author quxinjun
     * @updateTime 2021/5/27 11:57
     * @return: java.lang.String
     */
    public static String moveGroup(String groupId, String uid, String delId) {
        return String.format(GROUP_MOVED, getName(groupId, uid), getName(groupId, delId));
    }


    /**
     * @param name
     * @title setManager
     * @description 设置管理员
     * @author quxinjun
     * @updateTime 2021/5/27 17:59
     * @return: java.lang.String
     */
    public static String setManager(String name) {
        return String.format(GROUP_SET_MANAGER, name);
    }

    /**
     * @param name
     * @title setMember
     * @description 设置普通成员
     * @author quxinjun
     * @updateTime 2021/5/27 17:59
     * @return: java.lang.String
     */
    public static String setMember(String name) {
        return String.format(GROUP_SET_MEMBER, name);
    }

    /**
     * @param groupId 群组id
     * @param uid     操作用户id
     * @param names   名字
     * @param code    禁言描述
     * @title setBannedTip
     * @description 设置禁言
     * @author quxinjun
     * @updateTime 2021/5/28 10:17
     * @return: java.lang.String
     */
    public static String setBannedTip(String groupId, String uid, String names, Integer code) {
        return String.format(GROUP_SET_BANNED, getName(groupId, uid), names, EnumType.BannedCode.getDescByCode(code));
    }

    /**
     * 设置不能抢红包
     *
     * @param groupId
     * @param uid
     * @param names
     * @return
     */
    public static String setBanGradTip(String groupId, String uid, String names) {
        return String.format(GROUP_SET_BAN_GRAD, getName(groupId, uid), names);
    }

    /**
     * @param groupId 群组id
     * @param uid     操作人id
     * @param names   名字
     * @title cancelBannedTip
     * @description 取消禁言
     * @author quxinjun
     * @updateTime 2021/5/28 10:45
     * @return: java.lang.String
     */
    public static String cancelBannedTip(String groupId, String uid, String names) {
        return String.format(GROUP_CANCEL_BANNED, getName(groupId, uid), names);
    }

    public static String cancelBanGradTip(String groupId, String uid, String names) {
        return String.format(GROUP_CANCEL_BAN_GRAD, getName(groupId, uid), names);
    }

    /**
     * @param uid
     * @title joinGroupTip
     * @description 邀请入群
     * @author quxinjun
     * @updateTime 2021/5/28 17:09
     * @return: java.lang.String
     */
    public static String joinGroupTip(Long uid) {
        return String.format(GROUP_JOIN, UserUtils.getCacheUser(uid).getNickName());
    }

    /**
     * 谁被禁言
     *
     * @param groupId 群组id
     * @param uid     用户id
     * @param code    禁言编号
     */
    public static String isBannedTip(String groupId, String uid, Integer code) {
        return String.format(GROUP_IS_BANNED, getName(groupId, uid), EnumType.BannedCode.getDescByCode(code));
    }

    /**
     * 谁被禁止抢红包
     *
     * @param groupId
     * @param uid
     * @return
     */
    public static String isBanGradTip(String groupId, String uid) {
        return String.format(GROUP_IS_GRAD, getName(groupId, uid));
    }


    public static String isNonBannedTip(String groupId, String uid) {
        return String.format(GROUP_IS_NON_BANNED, getName(groupId, uid));
    }

    public static String isNonBanGradTip(String groupId, String uid) {
        return String.format(GROUP_IS_NON_BAN_GRAD, getName(groupId, uid));
    }

    /**
     * 撤回消息
     *
     * @param userName
     * @return
     */
    public static String undoMessageTip(String userName) {
        return String.format(GROUP_UNDO_MESSAGE, userName);
    }

    /**
     * 截屏通知
     *
     * @param name
     * @param currentTime
     * @return
     */
    public static String screensHotsTip(String name, String currentTime) {
        return String.format(GROUP_SCREEN_HOSTS, name, currentTime);
    }

}
